package core.controller.cmds;

import core.controller.CommandController;
import core.dal.WeightFunctionality;
import exceptions.UserNotFoundException;

public class EnterTestApplicationCMD implements ICmd{

	WeightFunctionality functionality;
	final String level = "Operator";
	ICmd nextCMD;
	
	CommandController cc;
	
	public EnterTestApplicationCMD(CommandController commandController, WeightFunctionality oF){
		this.cc = commandController;
		functionality = oF;
	}
	
	@Override
	public void setNextCmd(ICmd nextCmd) {
		nextCMD = nextCmd;
		
	}

	@Override
	public void execute(String cmd) {
		if (cmd.equals("enterTestApp")) {
			String pass;
			cc.getTUI().showOutput("Enter Password:");
			pass = cc.getTUI().getInput();
			
			if (functionality.getPassword().equals(pass)){
				cc.getTUI().showOutput("Entered app successfully");
				cc.setCurrentLevel("WeightApplication");
			}
			
		}

		if (nextCMD != null) {
			nextCMD.execute(cmd);
		}
	}

	@Override
	public String getInfo() {
		return "enterTestApp - Enter test app with pass protection";
		
	}

	@Override
	public String getLevel() {
		return this.level;
		
	}
}
